home *** CD-ROM | disk | FTP | other *** search
/ SGI Hot Mix 17 / Hot Mix 17.iso / HM17_SGI / research / examples / misc / wexmast / mbar.pro < prev    next >
Text File  |  1997-07-08  |  3KB  |  85 lines

  1. ; $Id: mbar.pro,v 1.3 1997/01/15 04:29:15 ali Exp $
  2. ;
  3. ; Copyright (c) 1993-1997, Research Systems, Inc.  All rights reserved.
  4. ;       Unauthorized reproduction prohibited.
  5.  
  6. ; This is the code for a simple menu bar.   Menu bars can be placed
  7. ; at the top of top-level widget bases.   While holding down the (left)
  8. ; mouse button, drag the cursor over the words in the menu bar.
  9. ; The appropriate menu will appear when the cursor is over the word.
  10. ; Release the mouse button on the desired menu item to make a selection.
  11.  
  12. ; Pull-right menus can be defined for any menu entry.   The pull-right
  13. ; menu can be activated by clicking on that menu item, or by dragging the
  14. ; cursor off the right side of that menu item.
  15.  
  16.  
  17. PRO mbar_event, event
  18. ; This is the event handler for a basic menu bar.
  19.  
  20. ; Use WIDGET_CONTROL to get the user value of any widget touched and put
  21. ; that value into 'eventval':
  22.  
  23. WIDGET_CONTROL, event.id, GET_UVALUE = eventval
  24.  
  25. ; The selection of a menu item is easily handled with a CASE statement.
  26. ; When a menu item is selected, the value of 'eventval' is the user value
  27. ; of the selected menu item.
  28.  
  29. CASE eventval OF
  30.     'QUIT':BEGIN
  31.         ; Quit the menu bar example.
  32.         WIDGET_CONTROL, event.top, /Destroy
  33.         END
  34.     ELSE:BEGIN
  35.         ; Print the button's user value to the IDL window:
  36.         PRINT, 'Widget User Value = ' + eventval
  37.         END
  38. ENDCASE
  39. END
  40.  
  41.  
  42.  
  43. PRO mbar, GROUP = GROUP
  44. ; This is the procedure that creates an example menu bar.
  45.  
  46. ; A top-level base widget with the title "Menu Bar Example" will
  47. ; hold the menu bar.   Since this is a top-level base (no parent),
  48. ; the "MBAR" keyword may be used.
  49.  
  50. base = WIDGET_BASE(TITLE = 'Menu Bar Example', MBAR=bar_base)
  51.  
  52. ; The "bar_base" variable now contains the widget base id for the menu bar.
  53.  
  54. ; The menus may now be constructed by creating button widgets with the
  55. ; "MENU" keyword.
  56.  
  57. file_menu = WIDGET_BUTTON(bar_base, Value='File', /Menu)
  58. file_bttn1 = WIDGET_BUTTON(file_menu, Value='File Item 1', Uvalue='FILE 1')
  59. file_bttn2 = WIDGET_BUTTON(file_menu, Value='File Item 2', Uvalue='FILE 2')
  60. file_bttn3 = WIDGET_BUTTON(file_menu, Value='File Item 3', Uvalue='FILE 3')
  61. file_bttn4 = WIDGET_BUTTON(file_menu, Value='Quit', Uvalue='QUIT')
  62.  
  63. opt_menu = WIDGET_BUTTON(bar_base, Value='Options', /Menu)
  64. opt_bttn1 = WIDGET_BUTTON(opt_menu, Value='Options Item 1', Uvalue='FILE 1')
  65. opt_bttn2 = WIDGET_BUTTON(opt_menu, Value='Options Item 2', Uvalue='FILE 2')
  66. opt_bttn3 = WIDGET_BUTTON(opt_menu, Value='Options Item 3', Uvalue='FILE 3')
  67. opt_pr = WIDGET_BUTTON(opt_menu, Value='Options Pull-Right', /Menu)
  68.    pr_bttn1 = WIDGET_BUTTON(opt_pr, Value='Pull-Right Item 1', Uvalue='PR 1')
  69.    pr_bttn2 = WIDGET_BUTTON(opt_pr, Value='Pull-Right Item 2', Uvalue='PR 2')
  70. opt_bttn5 = WIDGET_BUTTON(opt_menu, Value='Options Item 5', Uvalue='FILE 5')
  71.  
  72. help_menu = WIDGET_BUTTON(bar_base, Value='Help', /Menu)
  73. help_bttn1 = WIDGET_BUTTON(help_menu, Value='Help Item 1', Uvalue='HELP 1')
  74. help_bttn2 = WIDGET_BUTTON(help_menu, Value='Help Item 2', Uvalue='HELP 2')
  75.  
  76. ; Realize the widgets:
  77. WIDGET_CONTROL, base, /REALIZE
  78.  
  79. ; Hand off control of the widget to the XMANAGER:
  80. XMANAGER, "mbar", base, GROUP_LEADER = GROUP, /NO_BLOCK
  81.  
  82. END
  83.  
  84.  
  85.